package com.dt76.smallloanbackenduser.controller.xiaohao;

import com.dt76.smallloanbackenduser.pojo.xiaohao.ApprovalLoan;
import com.dt76.smallloanbackenduser.pojo.xiaohao.BorrowOrder;
import com.dt76.smallloanbackenduser.remote.xiaohao.BorrowOrderRemote;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class BorrowOrderController {

    @Resource
    private BorrowOrderRemote borrowOrderRemote;
//
//    @RequestMapping("/xiaohao/qryAll")
//    @ResponseBody
//    public List<BorrowOrder> qryAll(){
//        return borrowOrderRemote.qryAllOrder();
//    }

//    @RequestMapping("/qryAllByPage")
//    @ResponseBody
//    public List<BorrowOrder> qryAllByPage(Page){
//        return borrowOrderRemote.qryAllOrderByPage();
//    }

    //    @RequestMapping("/loanmanger/query")
//    public String loanQuery(Model model,@RequestBody(required = false) BorrowOrderQuery borrowOrderQuery){
//        model.addAttribute("borrowOrderQuery",borrowOrderQuery);
//        System.out.println(borrowOrderQuery.toString());
//        return "forward:/loanManger";
//    }
    @RequestMapping("/borrowOrder/addApproveLoan")
    @ResponseBody
    public Boolean addApprove(String boID, String id,String typeName) {
        boolean flag = false;
        BorrowOrder borrowOrder = borrowOrderRemote.qryByID(Integer.parseInt(boID));
        borrowOrder.setlType(typeName);
        //标明给客人放款是用哪个银行卡
        borrowOrder.setBankId(id);
        //修改订单状态
        borrowOrder.setBoType("放款处理");
        int i = borrowOrderRemote.modifyBorrowOrderType(borrowOrder);
        if (i > 0) {
            flag = true;
        }
        return flag;
    }

    @RequestMapping("loanhander/queryByboID")
    @ResponseBody
    public ApprovalLoan queryByBOId(String boID){
        BorrowOrder borrowOrder = borrowOrderRemote.qryByID(Integer.parseInt(boID));
        ApprovalLoan approvalLoan =  new ApprovalLoan();
        return  approvalLoan;
    };
}
